package create.prototype;

/**
 * @author dali
 * @date 2021-07-07 20:35
 * @Description 浅拷贝
 */

public class shallow implements Cloneable{
     int a;

     int[] time = {1,2,3};

    public shallow() {
        System.out.println("diao yong");
    }

    @Override
    public String toString() {
        return "shallow{" +
                "a=" + a +
                ", time=" + time +
                '}';
    }

    public static void main(String[] args) throws CloneNotSupportedException {
        shallow a = new shallow();
        shallow clone = (shallow) a.clone();
        System.out.println(clone);
        System.out.println(a == clone);
        clone.a = 2;
        clone.time[0] = 4;
        System.out.println(a.time[0]);
        System.out.println(clone.time[0]);
    }
}
